
***************************************
* create citizen datasets from WVS dataset of 45 countries
* in which confidence question was asked, May 2020 release 
***************************************


vers 16.1
capture log close
set more off 


*open and svyset data
******************************************

use "WVS_Cross-national_Wave_7_Stata_v20200502.dta", clear

* weighting (post-stratification weights + 1000-equilibrated weight)

svyset [pweight=S018], strata(B_COUNTRY)

* keep only WVS samples, as confidence questions on most IOs were not asked in EVS

tab A_STUDY, nol
tab A_STUDY //EVS==1
drop if A_STUDY==1

* keep 5 country sample

qui keep if B_COUNTRY==76|B_COUNTRY==276|B_COUNTRY==608|B_COUNTRY==643|B_COUNTRY==840
rename B_COUNTRY country
tab country

* code confidence variables

tab Q88
tab Q88, nol
rename Q88 confWHO
rename Q89 confWTO
rename Q87 confWB
rename Q83 confUN
rename Q84 confIMF
rename Q85 confICC
recode confWTO  -4/-1=. 4=0 3=1 1=3
recode confWHO  -4/-1=. 4=0 3=1 1=3
recode confIMF -4/-1=. 4=0 3=1 1=3
recode confUN -4/-1=. 4=0 3=1 1=3
recode confWB -4/-1=. 4=0 3=1 1=3
recode confICC -4/-1=. 4=0 3=1 1=3

sum confUN confIMF confICC confWB confWHO confWTO
gen confios= (confUN +confIMF +confICC +confWB +confWHO +confWTO)/6

* code correlates

* IVs: socioeconomic status
***************************

rename Q275 education
rename Q50 finsathousehold
recode finsathousehold 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
label drop Q50
label drop Q275


* IVs: domestic institutional trust
***********************

tab Q71
tab Q71, nol
rename Q71 confgov
recode confgov -4/-1=. 4=0 3=1 1=3


rename Q252 satis
recode satis 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
label drop Q252
rename satis polsatisfaction


* IVs: identification
***********************

rename Q257 feelcountry
tab feelcountry, nol
recode feelcountry 1=3 4=0 3=1
label drop Q257

rename Q259 feelworld
tab feelworld, nol
recode feelworld 1=3 4=0 3=1
label drop Q259


* IVs: political values
***********************

gen ordernation1 = Q154
recode ordernation1 -3 -2 -1=. 2=0 3=0 4=0
tab ordernation1, missing

gen ordernation2 = Q155
recode ordernation2 -3 -2 -1=. 2=0 3=0 4=0
tab ordernation2, missing

gen comb_ordernation = ordernation1+ordernation2
tab comb_ordernation
recode comb_ordernation 2=0 1=0 0=1 // code 0 for people who prioritized order in the nation (first or second place), code 1 is those who prioritized something else
tab comb_ordernation

rename Q182 homo
recode homo 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
tab homo
rename Q185 divorce
recode divorce 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
rename Q186 sexmarriage
recode sexmarriage 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
rename Q184 abort
recode abort 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9

gen ethliberal = (homo+divorce+sexmarriage+abort)/4
tab Q121
rename Q121 immigrants
recode immigrants 1=0 2=1 3=2 4=3 5=4

gen TAN_GAL = ((ethliberal/9)+(immigrants/4)+(comb_ordernation/2))
mean TAN_GAL
* mean =1.256538
gen gal=1 if TAN_GAL>1.256538
replace gal=0 if TAN_GAL<1.256538
replace gal=. if TAN_GAL==.
tab gal

rename Q240 leftright
recode leftright 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
label drop Q240

* IVs: controls
***********************

gen age = Q262
sum age 

tab Q57, nol
rename Q57 gentrust 
recode gentrust 2=0 
tab gentrust

gen male = Q260 // 1= male; 2= female
recode male 2=0  // 1= male; 0= female
tab male
label drop Q260

compress

save "wvs7.dta"


*Read in WVS7 csv data to get at the different codings for missing on the knowledge questions
*Code don't knows as 0, incorrect as 0, correct as 1, and rest as missing
*Merge to completely labeled WVS7 Stata file

clear
import delimited using WVS_Cross-National_Wave_7_csv_v2_0.csv

tab q91, missing
tab q92, missing
tab q93, missing

gen knUNSC_DK0 = q91
recode knUNSC_DK0 -1 1 2=0 3=1 -5/-2=.
gen knIMF_DK0 =q92
recode knIMF_DK0 1=1 -1 2 3=0 -5/-2=.
gen knAMN_DK0=q93
recode knAMN_DK0 -1 1 3=0 2=1 -5/-2=. 
gen polknow = knUNSC_DK0+knIMF_DK0+knAMN_DK0
tab polknow 
gen knowledge_DK0=polknow

keep knUNSC_DK0 knIMF_DK0 knAMN_DK0 knowledge_DK0 polknow d_interview
sort d_interview
compress
save know.dta, replace

use "wvs7.dta", clear
rename D_INTERVIEW d_interview
sort d_interview

merge d_interview using know.dta

drop if country==.

save "wvs7.dta", replace


* Also, use WVS7 csv data to better understand the meanings of missings for the figure notes, see also country-specific questionnaires

tab q275, missing
tab b_country
qui keep if b_country==76|b_country==276|b_country==608|b_country==643|b_country==840
tab b_country

tab q275 if b_country==840, missing
tab q275 if b_country==608, missing

tab q252 if b_country==840, missing
tab q252 if b_country==643, missing

